package cn.ante.org.service.impl;

import cn.ante.basic.utils.PageList;
import cn.ante.org.domain.Department;
import cn.ante.org.mapper.DepartmentMapper;
import cn.ante.org.query.DepartmentQuery;
import cn.ante.org.service.IDepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DepartmentServiceImpl implements IDepartmentService {
    @Autowired
    private DepartmentMapper departmentMapper;

    /*
    * @Title: loadAll
    * @Description: 根据高级查询的得到的集合
    * @Author: Nai
    * @Version: 1.0
    * @Date:  2022/6/21 18:57
    * @Parameters: [departmentQuery]
    * @Return cn.ante.basic.utils.PageList<cn.ante.org.domain.Department>
    */
    @Override
    public PageList<Department> loadAll(DepartmentQuery departmentQuery) {
        Integer total = departmentMapper.pageCount();
        List<Department> rows = departmentMapper.loadAll(departmentQuery);
        return new PageList<Department>(total,rows);

    }

    @Override
    public Department loadById(Long id) {
        return departmentMapper.loadById(id);
    }

    @Override
    public void add(Department department) {
        departmentMapper.add(department);
    }

    @Override
    public void upddate(Department department) {
        departmentMapper.upddate(department);
    }

    @Override
    public void remove(Long id) {
        departmentMapper.remove(id);
    }
}
